package com.dys.testclassaffect;

/**
 * @className: com.dys.testclassaffect.Boy
 * @description: com.dys.testclassaffect
 * @author: pine cone
 * @version: v1.0.0
 * @createTime: 2024/07/20 下午10:50
 */
public class Boy {
    // 属性封装
    private String name;
    private int age;

    // 方法
    public void buy() {
        System.out.println("跟我谈恋爱,我给你买买买...");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age < 0 || age > 150) {
            throw new IllegalArgumentException("Age must be between 0 and 150");
        }
        this.age = age;
    }

    public Boy() {
    }

    public Boy(String name, int age) {
        this.name = name;
        this.age = age;
    }
}
